chore: add #[non_exhaustive] and mutation methods to improve compatibility#715
Merged
alexhancock merged 4 commits intomainfrom Mar 3, 2026
Merged
chore: add #[non_exhaustive] and mutation methods to improve compatibility#715alexhancock merged 4 commits intomainfrom
alexhancock merged 4 commits intomainfrom
Conversation
alexhancock
previously approved these changes
Mar 2, 2026
alexhancock
previously approved these changes
Mar 3, 2026
d447ed7 to
3cad234
Compare
alexhancock
approved these changes
Mar 3, 2026
DaleSeo
reviewed
Mar 3, 2026
Comment on lines
+1459
to
+1466
| pub fn with_logger(level: LoggingLevel, logger: impl Into<String>, data: Value) -> Self { | ||
| Self { | ||
| level, | ||
| logger: Some(logger.into()), | ||
| data, | ||
| } | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
The with_ prefix means "take ownership of self, set a fieThe with_ prefix means "take ownership of self, set a field, and return self." When callers look at the method list, they'll expect to see new().with_logger("name") chaining. I suggest we stick to the conventional build pattern here.
Suggested change
| pub fn with_logger(level: LoggingLevel, logger: impl Into<String>, data: Value) -> Self { | |
| Self { | |
| level, | |
| logger: Some(logger.into()), | |
| data, | |
| } | |
| } | |
| } | |
| pub fn with_logger(mut self, logger: impl Into<String>) -> Self { | |
| self.logger = Some(logger.into()); | |
| self | |
| } |
Contributor
Author
There was a problem hiding this comment.
@DaleSeo I agree. I think most of them follow this pattern you're suggesting, and we should keep it consistent
This was referenced Mar 3, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In preparation for a 1.0 release, we should use #[non_exaustive] for most public structs/enums to help reduce backwards-incompatible changes.
While we don't foresee being strict with the semver guidelines, we should aim to keep backwards compatibility as much as possible between minor releases.
Motivation and Context
This will prevent clients from writing code that will break and require updates in future versions.
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context